package com.kevin.mybatis;


import com.kevin.mybatis.mapper.UserMapper;
import com.kevin.mybatis.pojo.SexEnum;
import com.kevin.mybatis.pojo.User;
import com.kevin.mybatis.utils.SqlSessionFactoryUtils;
import org.apache.ibatis.session.SqlSession;
import org.apache.log4j.Logger;

public class Test {
    public static void main(String[] args) {
        Logger logger = Logger.getLogger(Test.class);
        SqlSession sqlSession = null;
        try {
            sqlSession = SqlSessionFactoryUtils.openSqlSession();
            UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
//            userMapper.addUser(new User(6l, "root", "root", SexEnum.FEMALE));
//            sqlSession.commit();
            logger.info(userMapper.getUserById(6L).getSex().getSex());
        }catch (Exception e){
            e.printStackTrace();
            sqlSession.rollback();
        }finally {
            if (sqlSession!=null){
                sqlSession.close();
            }
        }
    }
}
